<%@ page import="com.car.entyti.User" %>
<%@ page import="com.car.service.UserService" %><%--
  Created by IntelliJ IDEA.
  User: 韩壮
  Date: 2021/5/26
  Time: 12:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="components/base.jsp" %>
<html>
<head>
    <title>用户中心</title>
    <link type="text/css" href="<%= request.getContextPath()%>/css/User.css" rel="stylesheet">
</head>
<body>

<%
    Cookie[] cookies = request.getCookies();
    String token = null;

    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals("TOKEN")) {
                token = cookie.getValue();
            }
        }
    }
    User user = new User();
    if (token == null) {
        out.print("<span> <a href=\"login.jsp\">登录</a></span>");

    } else {
        UserService userService = new UserService();
        user = userService.getUserByToken(token);
    }
%>

<div class="content">
    <div><strong>姓名</strong><input type="text" value="<%=user.getName()%>" disabled="disabled"></div>
    <div><strong>性别</strong><input type="text" value="<%=user.getSex()%>" disabled="disabled"></div>
    <div><strong>电话</strong><input type="text" value="<%=user.getPhone()%>" disabled="disabled"></div>
    <div><strong>类型</strong><input type="text" value="<%=user.getType()%>" disabled="disabled"></div>
    <div><strong>账户</strong><input type="text" value="<%=user.getAccount()%>" disabled="disabled"></div>
    <div><strong>密码</strong><input type="password" value="<%=user.getPassword()%>" disabled="disabled"></div>
    <div>
        <button class="user-button" type="button" onclick="location.href = 'updateUser.jsp'">修改</button>
        <button class="user-button" type="button" onclick="location.href = 'index.jsp'">返回</button>
    </div>
    <div class="bottom">
        <a href="wenti.jsp">出现问题？联系客服</a>
    </div>
</div>

</body>
</html>
